<template>
  <el-input v-bind="$attrs" v-on="$listeners" v-model="fieldValue" @change="$attrs.isAlias && inputChange()" >
    <template slot="prepend" v-if="$attrs.prepend">{{$attrs.prepend}}</template>
    <template slot="append" v-if="$attrs.append">{{$attrs.append}}</template>
  </el-input>
</template>

<script>
  import { getParent} from '../utils'
  import { getPropByPath } from 'element-ui/src/utils/util'
  import vPinyin from '@/utils/vue-py'

  export default {
    props: {
      value: {
        type: [String,Number]
      }
    },
    computed: {
      parent() {
        return getParent.call(this)
      },
      fieldValue: {
        get() {
          // console.log(this.$attrs,this.value,'--------------')
          return this.value
        },
        set(val) {
          console.log(888888888888,val)
          this.$emit('input', val)
        }
      }
    },
    methods:{
      inputChange(){
        console.log(888888888888)
        if(this.$attrs.aliasName) {
          const model = this.parent.currentModel;
          if(model) {
            model[this.$attrs.aliasName] = vPinyin.chineseToPinYin(this.fieldValue);
          }
        }
      }
    }
  }
</script>


